package com.zwan.oam_rtc.utils.messages;

import com.zwan.oam_rtc.utils.wintcp.ByteTransfer;

import java.nio.ByteBuffer;

public class FetchRedisDataMessage extends AbstractStruct {
    private byte[] messageBodyHeader = new byte[8];
    private byte[] tablename = new byte[50];
    private byte[] key = new byte[29];
    private static int LENGTH = 8+79;

    /**
     * 返回消息写入buffer
     */
    @Override
    public void writeToBuffer(ByteBuffer bf) {
        bf.put(messageBodyHeader);
        bf.put(tablename);
        bf.put(key);
    }

    /**
     * buffer读出返回消息
     */
    @Override
    public void readFromBuffer(ByteBuffer bf) {
        bf.get(messageBodyHeader);
        bf.get(tablename);
        bf.get(key);
    }

    public String getTablename() {
        return ByteTransfer.getString(tablename);
    }

    public void setTablename(String tablename) {
        ByteTransfer.str2Byte(tablename, this.tablename);
    }

    public String getKey() {
        return ByteTransfer.getString(key);
    }

    public void setKey(String key) {
        ByteTransfer.str2Byte(key, this.key);
    }


    @Override
    public int getLength() {
        return LENGTH;
    }
    public byte[] getMessageBodyHeader() {
        return messageBodyHeader;
    }


}

